home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFGraph / Application Source / ColumnGraphWindow.cp < prev    next >
Text File  |  1996-06-15  |  3KB  |  110 lines

  1. // ===========================================================================
  2. //    ColumnGraphWindow.cp                
  3. // ===========================================================================
  4. //
  5.  
  6. #include "ColumnGraphWindow.h"
  7.  
  8. #include <LApplication.h>
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <UDrawingState.h>
  12. #include <UMemoryMgr.h>
  13. #include <URegistrar.h>
  14.  
  15. #include "oofDrawStyleSet.h"
  16.  
  17. #define WIND_Graph        201
  18. #define PANE_Plot        301
  19.  
  20. // ---------------------------------------------------------------------------
  21. //        • ColumnGraphWindow
  22. // ---------------------------------------------------------------------------
  23. //    Constructor
  24.  
  25. ColumnGraphWindow::ColumnGraphWindow(LCommander* inSuperCommander, dbView *theView, StringPtr theTitle, unsigned long yAxisLength)
  26. {
  27.     // Make a window
  28.     mDisplayWindow = LWindow::CreateWindow(WIND_Graph, inSuperCommander);
  29.     
  30.     //let's find our WASTE pane..
  31.     CPlotPane *PlotView = (CPlotPane *) mDisplayWindow->FindPaneByID(PANE_Plot);
  32.     
  33.     Rect theFrame;
  34.     PlotView->CalcLocalFrameRect( theFrame );
  35.     
  36.     oofColor theColor(4474,3442,53247);
  37.     mDisplayWindow->FocusDraw();
  38.     
  39.     short fontNum;
  40.     ::GetFNum("\pPalatino",&fontNum); // Get my favourite font :)
  41.     if(fontNum==0)
  42.         ::TextFont(1);
  43.     else
  44.         ::TextFont(fontNum);
  45.     
  46.     mColumnGraphPtr = new oofColumnGraph(theFrame,theColor,theView,theTitle,yAxisLength);
  47.     mColumnGraphPtr->setDrawStyleSet(oofDrawStyleSetDefaultIteration());
  48.     
  49.     PlotView->SetGraph(mColumnGraphPtr);
  50.  
  51.     mDisplayWindow->Show();
  52. }
  53.  
  54.  
  55. // ---------------------------------------------------------------------------
  56. //        • ~ColumnGraphWindow
  57. // ---------------------------------------------------------------------------
  58. //    Destructor
  59.  
  60. ColumnGraphWindow::~ColumnGraphWindow()
  61. {
  62.     delete mDisplayWindow;
  63. }
  64.  
  65.  
  66. //    Register the functions to create our custom Pane classes
  67. void
  68. ColumnGraphWindow::RegisterClass()
  69. {
  70.     URegistrar::RegisterClass(LWindow::class_ID,  (ClassCreatorFunc)LWindow::CreateWindowStream);
  71.     URegistrar::RegisterClass(CPlotPane::class_ID,(ClassCreatorFunc)CPlotPane::CreatePlotPaneStream);
  72.     URegistrar::RegisterClass(LPrintout::class_ID,     (ClassCreatorFunc)LPrintout::CreatePrintoutStream);
  73.     URegistrar::RegisterClass(LPlaceHolder::class_ID, (ClassCreatorFunc)LPlaceHolder::CreatePlaceHolderStream);
  74. }
  75.  
  76. //-- Printing Stuff--
  77.  
  78. #define    Prto_PictText    901        //    Printout for printing the scrolling view
  79. #define    place_PictText    911        //    Placeholder for the main body
  80.  
  81. void
  82. ColumnGraphWindow::DoPrinting()
  83. {
  84.     // set graph to mono
  85.     mColumnGraphPtr->setStyleToMono();
  86.  
  87.     //    Read the Printout resource and find the place
  88.     //    holders for the scrolling view.
  89.  
  90.     LPrintout    *thePrintout = LPrintout::CreatePrintout(Prto_PictText);
  91.     LPlaceHolder *thePlace    = (LPlaceHolder*) thePrintout->FindPaneByID(place_PictText);
  92.  
  93.     //    Now find the view in this window 
  94.     //    and install it into its place holder.
  95.  
  96.     LView *theView    = (LView *) mDisplayWindow->FindPaneByID(PANE_Plot);
  97.     thePlace->InstallOccupant(theView, kAlignAbsoluteCenter);
  98.  
  99.         //    This is the function that starts the printing.
  100.  
  101.     thePrintout->DoPrintJob();
  102.  
  103.         //    The Printout's destructor takes care of setting the
  104.         //    views back to where they came from.
  105.  
  106.     delete thePrintout;
  107.  
  108.     mColumnGraphPtr->setStyleToColor();
  109. }
  110.